<script setup lang="ts">
import SeamlessScroll from "../../components2/seamless-scroll/seamless-scroll.vue";
import { computed, onMounted, reactive } from "vue";
import { useBigScreenSettingStore } from "../../../../../store/modules/bigscreensetting";
import { storeToRefs } from "pinia";
import EmptyCom from "../../components2/empty-com/empty-com.vue";
import { ElMessage } from "element-plus";

const settingStore = useBigScreenSettingStore();
const { defaultOption, indexConfig } = storeToRefs(settingStore);
const state = reactive<any>({
  list: [],
  defaultOption: {
    ...defaultOption.value,
    singleHeight: 256,
    limitScrollNum: 4,
  },
  scroll: true,
});

const getData = () => {
  var data = {"list":[{"provinceName":"广东省","cityName":"龙岩市","countyName":"扎鲁特旗","createTime":"2020-10-25 01:36:22","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10000,"onlineState":1},{"provinceName":"台湾","cityName":"巴中市","countyName":"其它区","createTime":"1985-05-04 07:59:03","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10001,"onlineState":0},{"provinceName":"江苏省","cityName":"厦门市","countyName":"其它区","createTime":"1997-11-28 23:45:13","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10002,"onlineState":0},{"provinceName":"澳门特别行政区","cityName":"兰州市","countyName":"昌乐县","createTime":"1980-02-05 17:45:29","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10003,"onlineState":0},{"provinceName":"福建省","cityName":"景德镇市","countyName":"-","createTime":"2013-02-24 08:26:03","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10004,"onlineState":1},{"provinceName":"河北省","cityName":"那曲地区","countyName":"东区","createTime":"1977-11-02 11:09:05","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10005,"onlineState":0},{"provinceName":"香港特别行政区","cityName":"福州市","countyName":"岳塘区","createTime":"2023-07-08 16:19:59","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10006,"onlineState":1},{"provinceName":"重庆","cityName":"威海市","countyName":"广阳区","createTime":"2005-12-10 08:57:26","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10007,"onlineState":1},{"provinceName":"江苏省","cityName":"石嘴山市","countyName":"工农区","createTime":"1971-07-19 18:35:35","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10008,"onlineState":1},{"provinceName":"上海","cityName":"秦皇岛市","countyName":"黔江区","createTime":"1992-11-16 02:34:00","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10009,"onlineState":0},{"provinceName":"广西壮族自治区","cityName":"新余市","countyName":"昭平县","createTime":"1983-03-01 12:54:23","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10010,"onlineState":1},{"provinceName":"贵州省","cityName":"九龙","countyName":"-","createTime":"1975-11-19 20:53:11","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10011,"onlineState":0},{"provinceName":"天津","cityName":"保山市","countyName":"-","createTime":"1988-03-29 02:59:34","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10012,"onlineState":0},{"provinceName":"福建省","cityName":"甘孜藏族自治州","countyName":"瑞安市","createTime":"1981-09-15 15:17:56","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10013,"onlineState":0},{"provinceName":"贵州省","cityName":"眉山市","countyName":"-","createTime":"1987-05-29 18:03:36","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10014,"onlineState":1},{"provinceName":"内蒙古自治区","cityName":"天津市","countyName":"黄岛区","createTime":"2022-11-03 07:57:01","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10015,"onlineState":1},{"provinceName":"江苏省","cityName":"庆阳市","countyName":"锡林浩特市","createTime":"2022-05-17 16:36:14","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10016,"onlineState":1},{"provinceName":"山西省","cityName":"日喀则地区","countyName":"其它区","createTime":"2009-09-29 22:27:55","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10017,"onlineState":1},{"provinceName":"新疆维吾尔自治区","cityName":"重庆市","countyName":"水城县","createTime":"2021-01-17 18:21:07","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10018,"onlineState":0},{"provinceName":"澳门特别行政区","cityName":"临沂市","countyName":"闸北区","createTime":"1970-05-12 12:42:52","deviceId":"6c512d754bbcd6d7cd86abce0e0cac58","gatewayno":10019,"onlineState":0}]};
  // leftBottom( { limitNum: 20 })
  //   .then((res) => {
  //     console.log("左下--设备提醒", res);
  //     if (res.success) {
        state.list = data.list;
    //   } else {
    //     ElMessage({
    //       message: res.msg,
    //       type: "warning",
    //     });
    //   }
    // })
    // .catch((err) => {
    //   ElMessage.error(err);
    // });
};
const addressHandle = (item: any) => {
  let name = item.provinceName;
  if (item.cityName) {
    name += "/" + item.cityName;
    if (item.countyName) {
      name += "/" + item.countyName;
    }
  }
  return name;
};
const comName = computed(() => {
  if (indexConfig.value.leftBottomSwiper) {
    return SeamlessScroll;
  } else {
    return EmptyCom;
  }
});
onMounted(() => {
  getData();
});
</script>

<template>
  <div class="left_boottom_wrap beautify-scroll-def" :class="{ 'overflow-y-auto': !indexConfig.leftBottomSwiper }">
    <component
      :is="comName"
      :list="state.list"
      v-model="state.scroll"
      :singleHeight="state.defaultOption.singleHeight"
      :step="state.defaultOption.step"
      :limitScrollNum="state.defaultOption.limitScrollNum"
      :hover="state.defaultOption.hover"
      :singleWaitTime="state.defaultOption.singleWaitTime"
      :wheel="state.defaultOption.wheel"
    >
      <ul class="left_boottom">
        <li class="left_boottom_item" v-for="(item, i) in state.list" :key="i">
          <span class="orderNum doudong">{{ i + 1 }}</span>
          <div class="inner_right">
            <div class="dibu"></div>
            <div class="flex">
              <div class="info">
                <span class="labels">设备ID：</span>
                <span class="text-content zhuyao doudong wangguan"> {{ item.gatewayno }}</span>
              </div>
              <div class="info">
                <span class="labels">时间：</span>
                <span class="text-content" style="font-size: 12px"> {{ item.createTime }}</span>
              </div>
            </div>

            <span
              class="types doudong"
              :class="{
                typeRed: item.onlineState == 0,
                typeGreen: item.onlineState == 1,
              }"
              >{{ item.onlineState == 1 ? "上线" : "下线" }}</span
            >

            <div class="info addresswrap">
              <span class="labels">地址：</span>
              <span class="text-content ciyao" style="font-size: 12px"> {{ addressHandle(item) }}</span>
            </div>
          </div>
        </li>
      </ul>
    </component>
  </div>
</template>

<style scoped lang="scss">
.left_boottom_wrap {
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.doudong {
  overflow: hidden;
  backface-visibility: hidden;
}

.overflow-y-auto {
  overflow-y: auto;
}

.left_boottom {
  width: 100%;
  height: 100%;

  .left_boottom_item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    font-size: 14px;
    margin: 10px 0;
    .orderNum {
      margin: 0 16px 0 -20px;
    }

    .info {
      margin-right: 10px;
      display: flex;
      align-items: center;
      color: #fff;

      .labels {
        flex-shrink: 0;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
      }

      .zhuyao {
        color: #1890ff;
        font-size: 15px;
      }

      .ciyao {
        color: rgba(255, 255, 255, 0.8);
      }

      .warning {
        color: #e6a23c;
        font-size: 15px;
      }
    }

    .inner_right {
      position: relative;
      height: 100%;
      width: 380px;
      flex-shrink: 0;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      .dibu {
        position: absolute;
        height: 2px;
        width: 104%;
        background-image: url("@/assets/img/zuo_xuxian.png");
        bottom: -10px;
        left: -2%;
        background-size: cover;
      }
      .addresswrap {
        width: 100%;
        display: flex;
        margin-top: 8px;
      }
    }

    .wangguan {
      color: #1890ff;
      font-weight: 900;
      font-size: 15px;
      width: 80px;
      flex-shrink: 0;
    }

    .time {
      font-size: 12px;
      // color: rgba(211, 210, 210,.8);
      color: #fff;
    }

    .address {
      font-size: 12px;
      cursor: pointer;
      // @include text-overflow(1);
    }

    .types {
      width: 30px;
      flex-shrink: 0;
    }

    .typeRed {
      color: #fc1a1a;
    }

    .typeGreen {
      color: #29fc29;
    }
  }
}
</style>
